package com.example.eurekaribbonhystrix;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class DcService {
    @Autowired
    RestTemplate restTemplate;

    @HystrixCommand(fallbackMethod = "error")
    public String dc() {
        String forObject = restTemplate.getForObject("http://eureka-client/dc", String.class);
        return restTemplate.getForObject("http://eureka-client/dc", String.class);
    }

    public String error(){
        return "服务器故障";
    }

}
